using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace MimeCloud.AssetManagement.Editor.Config
{
    public class RepositoryDetail : ConfigurationElement
    {
        [ConfigurationProperty("name", IsKey = true, IsRequired = true)]
        public string Name
        {
            get
            {
                return (string)this["name"];
            }
        }

        /// <summary>
        /// Provider Type
        /// </summary>
        [ConfigurationProperty("type", IsRequired = true)]
        public string Type
        {
            get { return ((string)this["type"]); }
        }

        [ConfigurationProperty("", IsRequired = false,IsDefaultCollection = true)]
        public KeyValueConfigurationCollection RepositorySettings
        {
            get { return (KeyValueConfigurationCollection)(this[""]); }
        }



        public string GetTypeName()
        {
            if (Type.IndexOf(',') > 0)
            {
                string[] splitType = Type.Split(new char[] { ',' }, 2);
                return splitType[0];
            }
            return Type;
        }

        public string GetTypeAssemblyName()
        {
            if (Type.IndexOf(',') > 0)
            {
                string[] splitType = Type.Split(new char[] { ',' }, 2);
                return splitType[1];
            }
            return Type;
        }
    }
}
